<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Order Form</title>
<link href="css/default.css" rel="stylesheet" type="text/css" />
<?php include('includes/path.php'); ?>

<script>
function showParts(str)
{
if (str=="")
  {
  document.getElementById("partvalues").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp1 =new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp1 =new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp1.onreadystatechange=function()
  {
  if (xmlhttp1.readyState==4 && xmlhttp1.status==200)
    {
    document.getElementById("partvalues").innerHTML=xmlhttp1.responseText;
    }
  }
xmlhttp1.open("GET","getparts.php?q="+str,true);
xmlhttp1.send();
}

function showOrders(str)
{
if (str=="")
  {
  document.getElementById("otherparts").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp2 = new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp2=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp2.onreadystatechange=function()
  {
  if (xmlhttp2.readyState==4 && xmlhttp2.status==200)
    {
    document.getElementById("otherparts").innerHTML=xmlhttp2.responseText;
    }
  }
xmlhttp2.open("GET","formOrder.php?q="+str,true);
xmlhttp2.send();
}

</script>


</head>

<body class="oneColFixCtrHdr">
<div id="container">
<?php include( 'includes/header.php' ); ?>
<?php include( 'includes/menu.php' ); ?>

<?php
	// This file inserts the following
	// variables: USER, PASS, DB
	include('db.php');

?>

  <div id="mainContent">
  	<h2>Finished Goods Inventory</h2>
   <div style='width: 450px; margin: 0px auto;'>
    <form action="" method="post" enctype="multipart/form-data" name="order" target="_parent">

    	<?php
        $TABLE1 = "Parts";
        $TABLE2 = "Parts_Required";
        $TABLE3 = "Finished_Goods";
        $ROW_NUMBER = 0;
        $PASS = "";
        $USER = "root";
        $HOST = "localhost";
        $CON = mysql_connect( $HOST, $USER, $PASS );
        $DB = "softengtestdatabase";
        if (!$CON)
          {
                  die('Could not connect: ' . mysql_error());
          }

        mysql_select_db( $DB );
        $QRY = 'SELECT fg_id, description FROM ' . $TABLE3;
        $result = mysql_query($QRY);
    echo "<p><center>Please select a finished good: ";
		echo "<select name = 'finishgood_list' onchange = 'showOrders(this.value); showParts(this.value)'>";

    while ($row = mysql_fetch_array($result))
		{
    		echo "<option value='" . $row['fg_id'] . "'>" . $row['fg_id'] . "</option>";
		}
		echo "</select></center></p>";
		echo "<div id='partvalues'></div>";

        mysql_close($CON);
  ?>
    </form>
    </div>
<h3>Please select the parts you wish to buy</h3>
<div id="otherparts"></div>
<!-- end #mainContent --></div>
<?php include('includes/footer.php'); ?>
<!-- end #container --></div>
</body>
</html>
